From 5911d8eb4886f60ba77c1bb1223265c631230fcf Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Fri, 13 Sep 2024 22:22:06 -0500 Subject: [PATCH] Move pgwui_core SQL related code into it's own module --- src/pgwui_copy/views/copy.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/pgwui_copy/views/copy.py b/src/pgwui_copy/views/copy.py index 86436fc..2a704f6 100644 --- a/src/pgwui_copy/views/copy.py +++ b/src/pgwui_copy/views/copy.py @@ -35,15 +35,13 @@ from wtforms import ( from pyramid.view import view_config import pgwui_core.forms +import pgwui_core.sql import pgwui_core.utils from pgwui_core.core import ( UploadEngine, NoTransactionEngine, SessionDBHandler, - LogSQLCommand, - SQLData, NoOpProcessor, - ExecuteSQL, ) from pgwui_core.exceptions import AuthFailError @@ -203,7 +201,7 @@ class CopySchemaHandler(SessionDBHandler): Side Effects: Yes, lots. ''' - return ExecuteSQL(ue, self) + return pgwui_core.sql.ExecuteSQL(ue, self) def render(self, errors, result): '''Instead of rendering, just our results so we can @@ -407,7 +405,7 @@ class DropSchemaHandler(CopySchemaHandler): to_db = uf['to_db'] # Drop the schema - sql.append(LogSQLCommand( + sql.append(pgwui_core.sql.LogSQLCommand( 'DROP SCHEMA {0} CASCADE'.format(schema), (), lambda ex: copy_ex.DropSchemaError(ex, schema, to_db), @@ -415,14 +413,14 @@ class DropSchemaHandler(CopySchemaHandler): log_failure=self.log_dropschema_failure)) # Vacuum the target db - sql.append(LogSQLCommand( + sql.append(pgwui_core.sql.LogSQLCommand( 'VACUUM FULL', (), lambda ex: copy_ex.VacuumFullError(ex, to_db), log_success=self.log_vacuumfull_success, log_failure=self.log_vacuumfull_failure)) - self.data = SQLData(sql) + self.data = pgwui_core.sql.SQLData(sql) class VacuumHandler(CopySchemaHandler): @@ -449,14 +447,14 @@ class VacuumHandler(CopySchemaHandler): to_db = uf['to_db'] # Vacuum the target db - sql.append(LogSQLCommand( + sql.append(pgwui_core.sql.LogSQLCommand( 'VACUUM ANALYZE', (), lambda ex: copy_ex.VacuumAnalyzeError(ex, to_db), log_success=self.log_vacuumanalyze_success, log_failure=self.log_vacuumanalyze_failure)) - self.data = SQLData(sql) + self.data = pgwui_core.sql.SQLData(sql) class CheckFromSchemaEngine(UploadEngine): -- 2.34.1